
<template>
    <view>
        <uv-popup ref="popup" @change="change" :closeable="true" width="500rpx">
            <view class="flex-center tn-p">{{ item?.name }}</view>
            <uv-line></uv-line>
            <scroll-view class="full" scroll-y="true">
                <view class="tn-p tn-pb-xl">
                    <uv-parse :content="item?.content"></uv-parse>

                    <uv-line margin="50rpx 0" />
                    <view class="flex-center" style="margin:50rpx 0 100rpx 0">

                        <uv-button type="success" shape="circle" style="width:180rpx;height:80rpx" text="同 意"
                            @click="okEvent" />
                        <uv-button type="error" shape="circle" style="width:180rpx;height:80rpx;margin-left:50rpx"
                            text="拒 绝" @click="erEvent" />
                    </view>
                </view>

            </scroll-view>
        </uv-popup>
    </view>
</template>

<script lang="ts">

import { TaDataBase } from "@/utils";
import { defineComponent } from "vue";

export default defineComponent({
    props: {
        show: {
            type: Boolean,
            default: false
        }
    },
    emits: ['change', 'update:show'],
    data() {
        return {
            item: <any>{}
        }
    },
    watch: {
        show(value: boolean) {
            value ? this.open() : this.close();
        }
    },
    methods: {
        open() {
            // @ts-ignore
            this.$refs.popup.open()
            this.loadData();

        },
        close() {
            // @ts-ignore
            this.$refs.popup.close()
        },
        change(e: any) {
            this.$emit('update:show', e.show)
        },
        okEvent() {
            this.$emit('change', true)
            this.close()
        },
        erEvent() {
            this.$emit('change', false)
            this.close()
        },
        loadData() {
            TaDataBase.agreement().then((ret: any) => {
                this.item = ret.data;

            })
        },
    }
})
</script>